<?php

class Somi_Form_Login extends Zend_Form 
{
	public function init()
	{
		
		require_once APPLICATION_HTDOCS.'/library/Somi/Validate/ErrorMessageDe.php';
		
		$translateValidators= new Somi_Validate_ErrorMessageDe();
		$translator = new Zend_Translate('array', $translateValidators->getTranslate());
    	Zend_Validate_Abstract::setDefaultTranslator($translator);
		
	
		$this->clearDecorators();

		
		#$this->setAction('/test/auth/login');
		#$this->setMethod('post');
		$this->setName('Login');	
			
			
		$formDecorators=array(
		'formElements',
		array('HtmlTag',array('tag'=>'dl','class'=>'zend_form')),
		'Form',
		);
		
		$elementDecorators=array(
		'ViewHelper',
		'Errors',
		array(array('data'=>'HtmlTag'),array('tag'=>'div','class'=>'element')),
		array('Label',array('class'=>'left')),
		array(array('row'=>'HtmlTag'),array('tag'=>'div','class'=>'row')),
		);
		
		$buttonDecorators=array(
		'ViewHelper',
		array(array('data'=>'HtmlTag'),array('tag'=>'div','class'=>'buttonrow')),
		array(array('row'=>'HtmlTag'),array('tag'=>'div'))
		);
		

		
		
		# Username
		$username=new Zend_Form_Element_Text('username');
		$username->setLabel('Benutzer');
		$username->setRequired(true)
		->addFilter('StripTags')
		->addFilter('StringTrim');
		#->addValidator('notEmpty');
		$username->addValidator('Alnum');
		#$username->setAttrib('class','username');
		#$username->setAttrib('style','margin:5px;');
		$username->setAttrib('size','40');
		#$username->setAttrib('autocomplete','off');
		#$username->setDecorators($decorators);
		
		# Password
		$password=new Zend_Form_Element_Password('password');
		$password->setLabel('Passwort');
		$password->setRequired(true)
		->addFilter('StripTags')
		->addFilter('StringTrim')
		->addValidator('notEmpty');
		#$password->setAttrib('class','password');
		#$password->setAttrib('style','margin:5px;');
		$password->setAttrib('size','40');
		#$password->setDecorators($decorators);
		
		
		#Submit
		$submit=new Zend_Form_Element_Submit('submit');
		$submit->setLabel('Login');
		$submit->setAttrib('class','form-button');
		


		# Send Elements
		$this->addElements(array($id,$username,$password,$submit));
			
		#$form->addDisplayGroup(array('username','password','submit'),'login');
		
		$this->setDecorators($formDecorators);
		$this->setElementDecorators($elementDecorators);
		$this->getElement('submit')->setDecorators($buttonDecorators);
	}
}


?>